package com.mystudy.leetcode.problem.tree.p_145;

import com.mystudy.leetcode.base.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 周志龙
 * @Email 15216876513@163.com
 * @Date on 2019/7/25 23:28
 * @Description 二叉树的后序遍历
 */
public class Solution {
    public List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> list = new ArrayList<>();
        postOrder(root,list);
        return list;
    }

    private void postOrder(TreeNode node, List list){
        if(node == null){
            return;
        }
        postOrder(node.left,list);
        postOrder(node.right,list);
        list.add(node.val);


    }
}
